import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/layouts/index.vue'

const router = createRouter({
	history: createWebHashHistory(),
	scrollBehavior() {
		return { top: 0 }
	},
	routes: [
		{
			path: '/',
			redirect: '/samples',
			name: 'Componets',
			meta: {
				visible: true,
				title: 'Componets',
				icon: 'mdi-cube-scan'
			},
			component: Layout,
			children: [
				{
					path: 'samples',
					name: 'Samples',
					meta: {
						title: 'Samples',
						icon: 'mdi-alpha-s',
						keepAlive: false,
						visible: true
					},
					component: () => import('@/views/componets/sample.vue'),
					children: []
				},
				{
					path: 'table',
					name: 'table',
					meta: {
						title: 'Table',
						icon: 'mdi-alpha-t',
						keepAlive: false,
						visible: true
					},
					component: () => import('@/views/componets/table.vue'),
					children: []
				},
				{
					path: 'calendar',
					name: 'calendar',
					meta: {
						title: 'Calendar',
						icon: 'mdi-alpha-c',
						keepAlive: false,
						visible: true
					},
					component: () => import('@/views/componets/calendar.vue'),
					children: []
				}
			]
		},
		{
			path: '/login',
			name: 'login',
			meta: {
				title: 'Login',
				icon: 'mdi-shield-account',
				visible: false
			},
			component: () => import('@/views/login/login.vue')
		},
		{ path: '/:pathMatch(.*)', name: 'Match', meta: { keepAlive: false }, redirect: '/404' },
		{
			path: '/404',
			name: '404',
			meta: { keepAlive: false, title: 'Not found', icon: 'mdi-paw-off', visible: false },
			component: Layout,
			children: [
				{
					path: '',
					name: 'd404',
					meta: {
						title: 'Not found',
						visible: false
					},
					component: () => import('@/views/feedback/no.vue'),
					children: []
				}
			]
		}
	]
})

router.beforeEach(async (to, _from, next) => {
	next()
})

router.afterEach(() => {})
export default router
